
****************************************************************************
**Win or Lose: Residential Sorting After a School Choice Lottery
*By Andrew Bibler & Stephen B Billings

****************************************************************************

clear all 
set more off

use all-lottery-movers-analysis.dta , clear

keep if year>2008

estpost su wonfirst

su wonfirst if ksample & year==2009 
estadd scalar won = r(mean)
estadd scalar wonsd = r(sd)
estadd scalar obs = r(N)

su winprob if ksample & year==2009 , det
estadd scalar won25 = r(p25)
estadd scalar won50 = r(p50)
estadd scalar won75 = r(p75)

est store C1

estpost su wonfirst 

su wonfirst if ksample & year==2010
estadd scalar won = r(mean)
estadd scalar wonsd = r(sd)
estadd scalar obs = r(N)

su winprob if ksample & year==2010 , det
estadd scalar won25 = r(p25)
estadd scalar won50 = r(p50)
estadd scalar won75 = r(p75)

est store C2

estpost su wonfirst 

su wonfirst if ksample & year==2011
estadd scalar won = r(mean)
estadd scalar wonsd = r(sd)
estadd scalar obs = r(N)

su winprob if ksample & year==2011 , det
estadd scalar won25 = r(p25)
estadd scalar won50 = r(p50)
estadd scalar won75 = r(p75)

est store C3

estpost su wonfirst

su wonfirst if ksample & year==2012
estadd scalar won = r(mean)
estadd scalar wonsd = r(sd)
estadd scalar obs = r(N)

su winprob if ksample & year==2012 , det
estadd scalar won25 = r(p25)
estadd scalar won50 = r(p50)
estadd scalar won75 = r(p75)

est store C4

esttab C1 C2 C3 C4 using kwinprobs.tex, replace ///
mtitles("2009" "2010" "2011" "2012") ///
label booktabs nonum collabels(none) nogaps f cells(none) ///
stats(won wonsd won25 won50 won75 obs, fmt(%10.2f %10.2f %10.2f %10.2f %10.2f %10.0fc) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{(@)}" " " " " "\multicolumn{1}{c}{@}" " " "\multicolumn{1}{c}{@}" " " "\multicolumn{1}{c}{@}" " " "\multicolumn{1}{c}{@}" ) ///
labels(`"Proportion Won First Choice"' `" "' `" "' `"\textit{Win Probabilities}"' `"25th Pctile"' `" "' `"50th Pctile"' `" "' `"75th Pctile"' `" "' `"Observations"' ))  


estpost su wonfirst 

su wonfirst if sixsample==1 & year==2009
estadd scalar won = r(mean)
estadd scalar wonsd = r(sd)
estadd scalar obs = r(N)

su winprob if sixsample==1 & year==2009 , det
estadd scalar won25 = r(p25)
estadd scalar won50 = r(p50)
estadd scalar won75 = r(p75)

est store C1

estpost su wonfirst

su wonfirst if sixsample==1 & year==2010
estadd scalar won = r(mean)
estadd scalar wonsd = r(sd)
estadd scalar obs = r(N)

su winprob if sixsample==1 & year==2010 , det
estadd scalar won25 = r(p25)
estadd scalar won50 = r(p50)
estadd scalar won75 = r(p75)

est store C2

estpost su wonfirst

su wonfirst if sixsample==1 & year==2011
estadd scalar won = r(mean)
estadd scalar wonsd = r(sd)
estadd scalar obs = r(N)

su winprob if sixsample==1 & year==2011 , det
estadd scalar won25 = r(p25)
estadd scalar won50 = r(p50)
estadd scalar won75 = r(p75)

est store C3

estpost su wonfirst 

su wonfirst if sixsample==1 & year==2012
estadd scalar won = r(mean)
estadd scalar wonsd = r(sd)
estadd scalar obs = r(N)

su winprob if sixsample==1 & year==2012 , det
estadd scalar won25 = r(p25)
estadd scalar won50 = r(p50)
estadd scalar won75 = r(p75)

est store C4

esttab C1 C2 C3 C4 using sixwinprobs.tex, replace ///
mtitles("2009" "2010" "2011" "2012") ///
label booktabs nonum collabels(none) nogaps f cells(none) ///
stats(won wonsd won25 won50 won75 obs, fmt(%10.2f %10.2f %10.2f %10.2f %10.2f %10.0fc) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{(@)}" " " " " "\multicolumn{1}{c}{@}" " " "\multicolumn{1}{c}{@}" " " "\multicolumn{1}{c}{@}" " " "\multicolumn{1}{c}{@}" ) ///
labels(`"Proportion Won First Choice"' `" "' `" "' `"\textit{Win Probabilities}"' `"25th Pctile"' `" "' `"50th Pctile"' `" "' `"75th Pctile"' `" "' `"Observations"' ))  


